<template>
  <el-dropdown trigger="click" @command="handleSetLanguage">
    <span class="el-dropdown-link">
      切换语言<i class="el-icon-arrow-down el-icon--right"></i>
    </span>
    <el-dropdown-menu slot="dropdown">
      <el-dropdown-item command="zh" :disabled="language === 'zh'">
        中文
      </el-dropdown-item>
      <el-dropdown-item command="ja" :disabled="language === 'ja'">
        Japanese
      </el-dropdown-item>
    </el-dropdown-menu>
  </el-dropdown>
</template>

<script>
export default {
  name: 'rs-lang-select',
  computed: {
    language() {
      return this.$store.state.app.language
    }
  },
  methods: {
    handleSetLanguage(lang) {
      this.$i18n.locale = lang
      this.$store.dispatch('setLanguage', lang)
      console.log(lang)
      //this.$message({
      //  message: 'switch language success',
      //  type: 'success'
      //})
    }
  }
}
</script>
